import React, { PureComponent, Fragment } from 'react';
import { connect } from 'dva';
import { Form, Radio, Input } from 'antd';

const FormItem = Form.Item;
const { TextArea } = Input;

@connect(({ product, loading }) => ({
  product,
  loading: loading.models.product,
}))
@Form.create()
class ProductFunctionService extends PureComponent {
  render() {
    const { form } = this.props;

    return (
      <Fragment>
        <FormItem label="功能名称" colon={false}>
          {form.getFieldDecorator('name', {
            rules: [{ required: true, message: '请填写功能名称' }],
          })(<Input placeholder="请填写功能名称" />)}
        </FormItem>
        <FormItem label="标识符" colon={false}>
          {form.getFieldDecorator('identifierCode', {
            rules: [{ required: true, message: '请填写标识符' }],
          })(<Input placeholder="请填写标识符" />)}
        </FormItem>
        <FormItem label="调用方式" colon={false}>
          {form.getFieldDecorator('callType', {
            initialValue: 1,
          })(
            <Radio.Group>
              <Radio value={1}>异步</Radio>
              <Radio value={2}>同步</Radio>
            </Radio.Group>,
          )}
        </FormItem>
        <FormItem label="描述" colon={false}>
          {form.getFieldDecorator(
            'desc',
            {},
          )(<TextArea style={{ width: 486 }} rows={4} placeholder="请输入描述" />)}
        </FormItem>
      </Fragment>
    );
  }
}

export default ProductFunctionService;
